package edu.jd.software.web.backend.controller;
import edu.jd.software.web.backend.common.api.CommonResult;
import edu.jd.software.web.backend.dto.UmsMenuNode;
import edu.jd.software.web.backend.service.UmsMenuService;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


@Controller
@Tag(name = "UmsMenuController",description = "后台菜单管理")
@RequestMapping("/menu")
public class UmsMenuController {
    @Autowired
    private UmsMenuService menuService;

    @Operation(summary = "树形结构返回所有菜单列表-函数方式")
    @RequestMapping(value = "/treeListCommon", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<List<UmsMenuNode>> treeListCommon() {
        List<UmsMenuNode> menuNodeList = null;
        menuNodeList =  menuService.treeListCommon();
        return CommonResult.success(menuNodeList);
    }


    @Operation(summary = "树形结构返回所有菜单列表-Stream方式")
    @RequestMapping(value = "/treeListStream", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<List<UmsMenuNode>> treeListStream() {
        List<UmsMenuNode> menuNodeList = null;

        //todo 调用 menuService.treeListStream()，返回 menuNodeList

        return CommonResult.success(menuNodeList);
    }
}
